package common

import (
	"fmt"
	"time"
	"os"
)

type Log struct {

}

func (l Log) Info(text ...interface{}) {
	l.Println(text, "INFO")
}

func (l Log) Error(text ...interface{}) {
	l.Println(text, "ERROR")
}

func (l Log) Debug(text ...interface{}) {
	l.Println(text, "DEBUG")
}

func (l Log) Warn(text ...interface{}) {
	l.Println(text, "WARN")
}

func (l Log) Println(text []interface{}, status string) {
	str := ""
	for _, s := range text {
		str += fmt.Sprintf("%v ", s)
	}
	fmt.Println(Colorize(fmt.Sprintf("[%s] [%s] %s", time.Now().Format("2006-01-02 15:04:05"), status, str), status))
}

func (l Log) Fatal(text ...interface{})  {
	l.Error(text)
	os.Exit(1)
}

var logger *Log

func GetLogger() *Log {
	if logger != nil {
		return logger
	}
	return new(Log)
}